<?php
/**
 * Created by PhpStorm.
 * User: phc
 * Date: 19-8-13
 * Time: 下午2:25
 */

namespace app\index\controller;

use app\common\model\CaseModel;
use think\Controller;

class CaseController extends Controller
{
    public function index()
    {
        $this->assign([
            'url' => '/index/case/caseList',
            'type' => 'case',
            'title' => '案例'
        ]);

        return $this->fetch('/list');
        //return $this->fetch('/case');
    }

    public function caseList()
    {
        $size = 10;
        $page = 1;
        $param = $this->request->get();
        if ($param && $param["size"] && $param["page"]) {
            $size = $param["size"];
            $page = $param["page"];
        }
        $caseModel = new CaseModel();
        $data = $caseModel->getCase($size, $page);
        $count = $caseModel->getCaseCount();
        return pagejson($data, $count);
    }

    public function detail($id = 0)
    {
        $caseModel = new CaseModel();
        $detail = $caseModel->getCaseById($id);
        $this->assign([
            'url' => $detail['image'][0]['phy'] ? $detail['image'][0]['phy'] : '',
            'gradient' => $detail['data']['title'] ? $detail['data']['title'] : '',
            'subhead' => $detail['data']['createtime'] ? $detail['data']['createtime'] : '',
            'detail' => $detail['data']['detail'] ? $detail['data']['detail'] : ''
        ]);

        return $this->fetch('/detail');
    }
}